const
  gulp = require('gulp'),
  connect = require('gulp-connect'),
  proxy = require('http-proxy-middleware')

gulp.task('default', ['server', 'watch'])

gulp.task('server', function() {
  connect.server({
    root: './',
    port: 233,
    host: '::',
    livereload:true,
    middleware: function (connect, opt) {
      return [
        proxy('/myhouse', {
          target: 'http://10.1.69.114:8088',
          changeOrigin: true
        })
      ]
    }
  })
})

gulp.task('reload',function(){
  gulp
    .src('./*')
    .pipe(connect.reload())
})

gulp.task('watch', function() {
  gulp.watch('./*', ['reload'])
  gulp.watch('./css/*', ['reload'])
  gulp.watch('./js/*', ['reload'])
})